﻿<%@ Page Title="" Language="C#" MasterPageFile="~/administrator/backend.Master" AutoEventWireup="true" CodeBehind="test-part-list.aspx.cs" Inherits="VQWEB.administrator.english.tests.test_part_list" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content_backend" runat="server">
    <div class="table-responsive">
        <table class="table table-bordered table-hover">
            <thead>
                <tr class="active">
                    <th>
                        #
                    </th>
                    <th>
                        <input name="chkAll" type="checkbox" value=" " />
                    </th>
                    <th>
                        Course
                    </th>
                    <th>
                        Test
                    </th>
                     <th>
                        Type
                    </th>
                    <th>
                        Part Test Title
                    </th>
                     <th>
                        Part Test Content
                    </th>
                    <th>
                        Files
                    </th>
                     <th>
                        Excercise
                    </th>
                    <th>
                        Active
                    </th>
                </tr>
            </thead>
            <tbody>
                
            </tbody>
        </table>
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Script_backend" runat="server">
    <script type="text/javascript">
        ShowToolBar("add");
        var url_ashx = "/admin/english/test/handler";
        $("#btnAdd").live("click", function () {
            window.location = "/admin/english/test/part/add";
        });
        $("#btnEdit").live("click", function () {
            var Id = "";
            Id = $("input[name='chkItem']:checked").first().attr("value");
            if (Id != undefined)
                window.location = "/admin/english/test/part/edit/" + Id;
        });
        $("#btnLockUnlock").live("click", function () {
            var array = new Array();
            $("input[name='chkItem']:checked").each(function (i) {
                array[i] = this.value;
            });
            if (array.length > 0) {
                $.post(url_ashx, { lockunlock_test_part: JSON.stringify(array) }, function (data) {
                    var plusData = $.parseJSON(data);
                    $("tbody").empty();
                    ShowTestPartHtml(plusData);
                });
            }
        });
        //Delete
        $("#btnDelete").live("click", function () {
            var array = new Array();
            $("input[name='chkItem']:checked").each(function (i) {
                array[i] = this.value;
            });
            if (array.length > 0) {
                if (confirm("Bạn muốn xóa bản ghi không ???")) {
                    $.post(url_ashx, { delete_test_part: JSON.stringify(array) }, function (data) {
                        var plusData = $.parseJSON(data);
                        $("tbody").empty();
                        ShowTestPartHtml(plusData);
                    });
                }
            }

        });
        //list 
        $(document).ready(function () {
            $.post(url_ashx, { list_test_part: "view_test_part" }, function (data) {
                var plusData = $.parseJSON(data);
                ShowTestPartHtml(plusData);
            });
        });

        //function show
        function ShowTestPartHtml(table) {
            var html = "";
            $.each(table, function (i, obj) {
                html += "<tr>";
                html += "<td>";
                html += i + 1;
                html += "</td>";
                html += "<td>";
                html += "<input name=\"chkItem\" type=\"checkbox\" value=" + obj.part_test_id + " />";
                html += "</td>";
                html += "<td>";
                html += obj.course;
                html += "</td>";
                html += "<td>";
                html += obj.test_title;
                html += "</td>";
                html += "<td>";
                html += obj.type_code;
                html += "</td>";
                html += "<td>";
                html += obj.part_test_title;
                html += "</td>";
                html += "<td>";
                html += obj.part_test_content;
                html += "</td>";
                html += "<td>";
                html += obj.part_test_file;
                html += "</td>";
                html += "<td>";
                html += obj.excercise;
                html += "</td>";
                html += "<td>";
                html += (obj.part_test_active == true) ? "kich hoat" : "chua kich hoat";
                html += "</td>";
                html += "</tr>";
            });
            $("tbody").append(html);
        }

    </script>
</asp:Content>
